import { createRouter, createWebHistory } from 'vue-router'

// 导入视图组件
import HomeView from '../views/HomeView.vue'

// 由于不需要登录界面，我们直接从主页开始
const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta: { title: '减肥大师' }
  },
  {
    path: '/food-recognition',
    name: 'foodRecognition',
    component: () => import('../views/FoodRecognitionView.vue'),
    meta: { title: '食物识别' }
  },
  {
    path: '/diet',
    name: 'diet',
    component: () => import('../views/DietView.vue'),
    meta: { title: '饮食计划' }
  },
  {
    path: '/exercise',
    name: 'exercise',
    component: () => import('../views/ExerciseView.vue'),
    meta: { title: '运动计划' }
  },
  {
    path: '/tracking',
    name: 'tracking',
    component: () => import('../views/TrackingView.vue'),
    meta: { title: '数据追踪' }
  },
  {
    path: '/profile',
    name: 'profile',
    component: () => import('../views/ProfileView.vue'),
    meta: { title: '个人资料' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '减肥大师'
  next()
})

export default router 